<?php

namespace App\Http\Controllers;

use App\Lessons;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class LessonController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function view(Request $request)
    {
        $id = $request->id;
        $id = ($id) ? intval($id) : 0;
        if (!$id) {
            return redirect("/");
        }

        $lesson = Lessons::where('id',$id)->first();

        $data = array();
        if ($lesson) {
            $data['lesson'] = $lesson;
        }
        return view('lesson',$data);
    }
}
